/*
 * Copyright (c) 2011 Ball State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.bsu.android.gtv.apps.bconnected.objects;

/**
 * EventType object
 * @author Kyle Parker, University Computing Services
 */
public class EventType implements Comparable<EventType> {
	private String calendarEventID;
	private String calendarEventName;
	private String eventCount;

	public String getCalendarEventID() {		
		return calendarEventID;
	}
	public void setCalendarEventID(String value)  {
		this.calendarEventID = value.trim();
	}

	public String getCalendarEventName() {		
		return calendarEventName;
	}
	public void setCalendarEventName(String value) {
		this.calendarEventName = value.trim();
	}

	public String getEventCount() {		
		return eventCount;
	}
	public void setEventCount(String value) {
		this.eventCount = value.trim();
	}
	
	public EventType copy() {
		EventType copy = new EventType();
		copy.calendarEventID = calendarEventID;
		copy.calendarEventName = calendarEventName;
		copy.eventCount = eventCount;
		return copy;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime * result + ((calendarEventID == null) ? 0 : calendarEventID.hashCode());
		result = prime * result + ((calendarEventName == null) ? 0 : calendarEventName.hashCode());
		result = prime * result + ((eventCount == null) ? 0 : eventCount.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) { return true; }
		
		if (obj == null) { return false; }
		
		if (getClass() != obj.getClass()) { return false; }
		
		EventType other = (EventType) obj;
		
		if (calendarEventID == null)  {
			if (other.calendarEventID != null) { return false; }
		} else if (!calendarEventID.equals(other.calendarEventID)) { return false; }
		
		if (calendarEventName == null) {
			if (other.calendarEventName != null) { return false; }
		} else if (!calendarEventName.equals(other.calendarEventName)) { return false; }
		
		if (eventCount == null) {
			if (other.eventCount != null) { return false; }
		} else if (!eventCount.equals(other.eventCount)) { return false; }
		
		return true;
	}

	public int compareTo(EventType another) {
		if (another == null) return 1;
		// sort descending, most recent first
		return another.calendarEventID.compareTo(calendarEventID);
	}
}
